package com.matt.repository.impl;

import com.matt.repository.base.BaseNativeSqlRepository;
import com.matt.repository.base.StaffResourceRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/8/2
 * *******************************
 */
@Service
public class StaffResourceRepositoryImpl extends BaseNativeSqlRepository implements StaffResourceRepository{

    @Override
    public List<Object[]> findResourcesByStaff(String staffId) {
        String findTeacherSql=String.format("SELECT  r.resourceName,r.resourceUrl, r.lvl, r.pid, r.`comment` " +
                "from rel_staff_role sr LEFT JOIN rel_role_resource rr ON sr.roleId =rr.roleId LEFT JOIN Resource r ON rr.resourceId = r.id " +
                " where sr.staffId = '%s'", staffId);
        List<Object[]> objectArrayList = sqlArrayList(findTeacherSql);
        return objectArrayList;
    }
}
